using System;
using System.Collections.Generic;

namespace Quintsys.Common.Repositories
{
    /// <summary>
    ///     Generic Repository
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IRepository<T> where T : class
    {
        /// <summary>
        ///     Gets all entities of type T as Enumerable.
        /// </summary>
        /// <returns></returns>
        IEnumerable<T> GetAll();

        /// <summary>
        ///     Finds the entities specified by predicate.
        /// </summary>
        /// <param name="predicate">The predicate.</param>
        /// <returns></returns>
        IEnumerable<T> Find(Func<T, bool> predicate);

        /// <summary>
        ///     Gets the entity specified by the predicate.
        /// </summary>
        /// <param name="predicate">The predicate.</param>
        /// <returns></returns>
        T Get(Func<T, bool> predicate);

        /// <summary>
        ///     Adds the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Add(T entity);

        /// <summary>
        ///     Deletes the entity specified by the predicate.
        /// </summary>
        /// <param name="predicate">The predicate.</param>
        void Delete(Func<T, bool> predicate);

        /// <summary>
        ///     Deletes the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Delete(T entity);

        /// <summary>
        ///     Saves this instance.
        /// </summary>
        void Save();
    }
}